#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAXN = 2 * 1e5 + 1000;

int d[MAXN], v[MAXN], a[MAXN], pre[2000055], nxt[2000055], id[MAXN];

struct node{
    int L, R;
}tr[MAXN], getans[MAXN];

bool cmp(node a, node b){
    return a.R < b.R;
}

void solve(){
    memset(pre, 0, sizeof pre);
    memset(nxt, 0, sizeof nxt);
    int n, m, L, V;
    cin >> n >> m >> L >> V;
    for(int i = 1; i <= n; ++ i)
        cin >> d[i] >> v[i] >> a[i];

    for(int i = 1; i <= m; ++ i)
        cin >> id[i];

    sort(id + 1, id + m + 1);

    for(int i = 1; i <= m; ++ i)
        pre[id[i]] = nxt[id[i]] = i;

    for(int i = L; i >= 0; -- i)
        if(nxt[i] == 0) nxt[i] = nxt[i + 1];
    for(int i = 1; i <= L; ++ i)
        if(pre[i] == 0) pre[i] = pre[i - 1];


    for(int i = 1; i <= n; ++ i){
        tr[i].L = 0; tr[i].R = 0;
        if(a[i] == 0 && v[i] <= V) continue;
        if(a[i] < 0 && v[i] <= V) continue;
        if(a[i] == 0 && v[i] > V){
            tr[i].L = nxt[d[i]];
            tr[i].R = pre[L];
            continue;
        }
        if(a[i] > 0 && v[i] > V){
            tr[i].L = nxt[d[i]];
            tr[i].R = pre[L];
            continue;
        }
        long long tmp = V * 1LL * V * 1LL;
        long long tmp2 = v[i] * 1LL * v[i] * 1LL;
        long long t = tmp - tmp2;
        long long ttt = 2 * a[i];

        long long tmpans = t / ttt + d[i];
        if(a[i] > 0){
            if(t % ttt != 0) tmpans ++;
            if(tmpans <= L){
                tr[i].L = nxt[tmpans];
                tr[i].R = pre[L];
            }
        }
        if(a[i] < 0){
            tr[i].L = nxt[d[i]];
            tr[i].R = pre[min(tmpans, L * 1LL)];
        }


    }
    int cnt = 0;
    for(int i = 1; i <= n; ++ i)
        if(tr[i].L <= tr[i].R && tr[i].L != 0)
            getans[++ cnt] = tr[i];

    sort(getans + 1, getans + cnt + 1, cmp);

    int last = -1;
    int ans = 0;

    for(int i = 1; i <= cnt; ++ i){
        if(getans[i].L > last){
            last = getans[i].R;
            ++ans;
        }
    }
    cout << cnt << " " << m - ans << endl;
}

signed main(){

    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int T;
    cin >> T;
    while(T--) solve();

    return 0;
}